package com.deng.wxmessagecallback.utils.message;

import com.deng.wxmessagecallback.utils.CommonUtils;
import me.chanjar.weixin.common.util.crypto.WxCryptUtil;
import me.chanjar.weixin.cp.bean.message.WxCpXmlOutMessage;
import me.chanjar.weixin.cp.util.xml.XStreamTransformer;

/**
 * @author wbdengtt
 * @date 2021/1/12 13:22
 * 默认的消息回复模板
 */
public class DefaultTemplate {
    public static String getTextMessage(String fromUserName, String toUserName) {
        String content = "这是一条默认的文本回复消息";
        WxCpXmlOutMessage wxCpXmlOutMessage = WxCpXmlOutMessage.TEXT().content(content).fromUser(fromUserName)
                .toUser(toUserName).build();
        wxCpXmlOutMessage.setCreateTime(System.currentTimeMillis());
        WxCryptUtil wxCryptUtil = new WxCryptUtil(CommonUtils.sToken,CommonUtils.sEncodingAESKey,CommonUtils.sCorpID);
        return wxCryptUtil.encrypt(XStreamTransformer.toXml((Class)wxCpXmlOutMessage.getClass(),wxCpXmlOutMessage));
    }
}
